package com.sss.otep.service;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sss.otep.orm.model.Member;
import com.sss.otep.orm.model.MemberPaidDept;
import com.sss.otep.orm.repository.MemberPaidDeptRepository;
import com.sss.otep.orm.repository.MemberRepository;

@Service
public class OTEPServiceImpl implements OTEPService {	
	private static final Logger log = LoggerFactory.getLogger(OTEPServiceImpl.class);
	@Autowired
	private MemberRepository memberRepo;
	@Autowired
	private MemberPaidDeptRepository memberPaidDeptRepo;
	
	@Override
	public List<Member> loadMember(LoadParameter param) {
		List<Member> result = null;
		try{
			result = memberRepo.findByCriteria(param.getId(),
					param.getIdCard(), 
					param.getName(), 
					param.getSurname());
		}
		catch(Exception e){
			log.error("Load member error occure...",e);
		}
		return result;
	}

	@Override
	public List<MemberPaidDept> loadMemberPaidDept(LoadParameter param) {
		List<MemberPaidDept> result = null;
		try{
			result = memberPaidDeptRepo.findByCriteria(param.getId(),
					param.getIdCard(), 
					param.getName(), 
					param.getSurname());
		}
		catch(Exception e){
			log.error("Load member paid dept error occure...",e);
		}
		return result;
	}



}
